/* zhengYu */

import request from '@/utils/request'

// 查询家庭表列表
export function listDocFamily(query) {
    return request({
        url: '/familyManagement/docFamily/list',
        method: 'get',
        params: query
    })
}

// 查询家庭表详细
export function getDocFamily(famliyId) {
    return request({
        url: '/familyManagement/docFamily/' + famliyId,
        method: 'get'
    })
}

// 新增家庭表
export function addDocFamily(data) {
    return request({
        url: '/familyManagement/docFamily',
        method: 'post',
        data: data
    })
}

// 修改家庭表
export function updateDocFamily(data) {
    return request({
        url: '/familyManagement/docFamily',
        method: 'put',
        data: data
    })
}

// 删除家庭表
export function delDocFamily(famliyId) {
    return request({
        url: '/familyManagement/docFamily/' + famliyId,
        method: 'delete'
    })
}

// 根据用户id查询用户家庭信息
export function getDocFamilyByUserId() {
    return request({
        url: '/familyManagement/docFamily/findFamilyByUserId/',
        method: 'get'
    })
}

// ================== 地址管理 ==================

// 获取所有省份
export function getAllProvince() {
    return request({
        url: '/FamilyAddress/docAddress/getAllProvince',
        method: 'get'
    })
}

// 根据省份id获取城市
export function getAllCities(provinceId) {
    return request({
        url: '/FamilyAddress/docAddress/getAllCities',
        method: 'get',
        params: {provinceId}
    })
}

// 根据城市id获取区/县
export function getAllDistricts(cityId) {
    return request({
        url: '/FamilyAddress/docAddress/getAllDistricts',
        method: 'get',
        params: {cityId}
    })
}

// 添加家庭信息
export function addFamilyVO(familyData) {
    return request({
        url: '/familyManagement/docFamily/addFamilyVO', // 注意接口路径要和后端一致
        method: 'post',
        data: familyData
    });
}

// 添加家庭中间表
export function addFamilyUser() {
    return request({
        url: '/familyManagement/docFamily/addFamilyUser',
        method: 'post'
    });
}

// 获取家庭成员信息
export function getFamilyUserInfo() {
    return request({
        url: '/familyManagement/docFamily/getFamilyUserInfo',
        method: 'get'
    });
}

// 添加家庭成员
export function addFamilyUserInfo(familyUsername) {
    return request({
        url: '/familyManagement/docFamily/addFamilyUser/' + familyUsername,
        method: 'post',
        data: familyUsername
    });
}

// 修改家庭信息
export function updateFamilyInfo(familyInfo) {
    return request({
        url: '/FamilyAddress/docAddress/updateFamilyInfo',
        method: 'post',
        data: familyInfo
    });
}

// 成员添加校验
export function checkAddFamilyUser(username) {
    return request({
        url: '/familyManagement/docFamily/checkAddFamilyUser/' + username,
        method: 'post',
        data: username
    });
}

// 校验是否已存在家庭
export function checkNotFamily() {
    return request({
        url: '/familyManagement/docFamily/checkNotFamily',
        method: 'get'
    })
}

// 根据用户id查询用户家庭信息和已签约列表信息
export function getFamilyAndContractInfo() {
    return request({
        url: '/familyManagement/docFamily/findFamilyByUserIdAndContracted',
        method: 'get'
    })
}
